<?php
  include_once("../sql_connect.php");
  include_once("../msg_redirect.php");
?>
<?php
/*用于将评论写入数据库*/

/*检查comment表中得最大c_id（评论编号）*/
$my_sql = mysql_query("select MAX(c_id) from comment",$connection);
$my_result = mysql_fetch_array($my_sql);

/*检查comment表中w_id（微博id）最大w_ctimes（微博评论次数）*/
$comment_sql = mysql_query("select MAX(w_ctimes) from comment WHERE w_id = '$w_id'",$connection);	
$comment_result = mysql_fetch_array($comment_sql);


/*对将要输入comment表的数据项量进行赋值*/
$c_id = $my_result[0] + 1;
$c_content = $_POST[comment_content];
$u_no = $_COOKIE['u_no'];
$w_id = $_POST[w_id];

/*检查comment表中w_id（微博id）最大w_ctimes（微博评论次数）*/
$comment_sql = mysql_query("select MAX(w_ctimes) from comment WHERE w_id = '$w_id'",$connection);	
$comment_result = mysql_fetch_array($comment_sql);

$w_ctimes = $comment_result[0] +1;
$c_date = time();

$my_sql = mysql_query("insert into comment values('$c_id','$c_content','$u_no','$w_id','$w_ctimes','$c_date','')",$connection);

?>